package cn.jly.boot.mp.bean;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import javax.persistence.PostUpdate;
import java.io.Serializable;
import java.util.Objects;

/**
 * @author lanyangji
 * @description user entity
 * @date 2020/12/25 下午 3:15
 */
@TableName("user")
public class User implements Serializable {
    @PostUpdate
    void postUpdate(Object object) {
        System.out.println("---> User.postUpdate");
    }

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    private String username;
    private String email;
    private Integer age;
    @TableField(value = "department_id")
    private Integer deptId;

    public User() {
    }

    public User(Long id, String username, String email, Integer age, Integer deptId) {
        this.id = id;
        this.username = username;
        this.email = email;
        this.age = age;
        this.deptId = deptId;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Integer getDeptId() {
        return deptId;
    }

    public void setDeptId(Integer deptId) {
        this.deptId = deptId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        User user = (User) o;
        return id.equals(user.id) && username.equals(user.username) && email.equals(user.email) && age.equals(user.age) && deptId.equals(user.deptId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, username, email, age, deptId);
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", username='" + username + '\'' +
                ", email='" + email + '\'' +
                ", age=" + age +
                ", deptId=" + deptId +
                '}';
    }
}
